import {
  Search,
  Plus,
  Delete,
  Tools,
  HomeFilled,
  Menu,
  Avatar,
  StarFilled,
  Histogram,
  Grid,
  HelpFilled,
  Minus,
  CirclePlus,
  Female,
  Aim,
  House,
  FullScreen,
  Service,
  Link,
  Pointer,
  Star,
  Notification,
  Connection,
  ChatDotRound,
  Setting,
  Clock,
  Position,
  Discount,
  Message,
  QuestionFilled,
  UserFilled,
  Refresh,
  WarnTriangleFilled,
  Warning,
} from "@element-plus/icons-vue";
import store from "@/store/index";
import { toRaw } from '@vue/reactivity'

export const InitIcon = (strIcon) => {
  switch (strIcon) {
    case "Tools":
      return Tools;
    case "HomeFilled":
      return HomeFilled;
    case "Delete":
      return Delete;
    case "Menu":
      return Menu;
    case "Avatar":
      return Avatar;
    case "StarFilled":
      return StarFilled;
    case "Grid":
      return Grid;
    case "Histogram":
      return Histogram;
    case "HelpFilled":
      return HelpFilled;
    case "Minus":
      return Minus;
    case "CirclePlus":
      return CirclePlus;
    case "Female":
      return Female;
    case "Aim":
      return Aim;
    case "House":
      return House;
    case "FullScreen":
      return FullScreen;
    case "Service":
      return Service;
    case "Link":
      return Link;
    case "Pointer":
      return Pointer;
    case "Star":
      return Star;
    case "Notification":
      return Notification;
    case "Connection":
      return Connection;
    case "ChatDotRound":
      return ChatDotRound;
    case "Setting":
      return Setting;
    case "Clock":
      return Clock;
    case "Position":
      return Position;
    case "Discount":
      return Discount;
    case "Message":
      return Message;
    case "QuestionFilled":
      return QuestionFilled;
    case "UserFilled":
      return UserFilled;
    case "Search":
      return Search;
    case "Plus":
      return Plus;
    case "Refresh":
      return Refresh;
    case "WarnTriangleFilled":
      return WarnTriangleFilled;
    case "Warning":
      return Warning;
    default:
      return House;
  }
}

export const IconSource = () => {
  let arr = [
    {
      "value": "Search",
      "label": '搜索'
    },
    {
      "value": "Plus",
      "label": '加号'
    },
    {
      "value": "Delete",
      "label": '删除'
    },
    {
      "value": "Tools",
      "label": '工具'
    },
    {
      "value": "HomeFilled",
      "label": '主页(填充)'
    },
    {
      "value": "Menu",
      "label": '菜单'
    },
    {
      "value": "Avatar",
      "label": '人像'
    },
    {
      "value": "StarFilled",
      "label": '星星(填充)'
    },
    {
      "value": "Histogram",
      "label": '柱状图'
    },
    {
      "value": "Grid",
      "label": '网格'
    },
    {
      "value": "HelpFilled",
      "label": '帮助(填充)'
    },
    {
      "value": "Minus",
      "label": '减号'
    },
    {
      "value": "CirclePlus",
      "label": '加号(圆形)'
    },
    {
      "value": "Female",
      "label": '女性'
    },
    {
      "value": "Aim",
      "label": '准星'
    },
    {
      "value": "House",
      "label": '房子'
    },
    {
      "value": "FullScreen",
      "label": '全屏'
    },
    {
      "value": "Service",
      "label": '服务'
    },
    {
      "value": "Link",
      "label": '链接'
    },
    {
      "value": "Pointer",
      "label": '指针'
    },
    {
      "value": "Star",
      "label": '星'
    },
    {
      "value": "Notification",
      "label": '通知'
    },
    {
      "value": "Connection",
      "label": '连接'
    },
    {
      "value": "ChatDotRound",
      "label": '圆形聊天框(点)'
    },
    {
      "value": "Setting",
      "label": '齿轮'
    },
    {
      "value": "Clock",
      "label": '时钟'
    },
    {
      "value": "Position",
      "label": '位置'
    },
    {
      "value": "Discount",
      "label": '价签'
    },
    {
      "value": "Message",
      "label": '消息'
    },
    {
      "value": "QuestionFilled",
      "label": '问号(填充)'
    },
    {
      "value": "UserFilled",
      "label": '用户(填充)'
    },
    {
      "value": "Refresh",
      "label": '刷新'
    },
    {
      "value": "WarnTriangleFilled",
      "label": "填充警告三角形"
    },
    {
      "value": "Warning",
      "label": "警告"
    }
  ]

  return arr;
}

export const StatusType = (item) => {
  switch (item) {
    case 0:
      return '未激活';
    case 1:
      return '正常';
    case -1:
      return '冻结';
    case -2:
      return '已删除';
    default:
      return '异常';
  }
}

export const currentMenuPermission = (menuId) => {
    var result = new Array(); 
    let buttons = toRaw(store().$state.buttons);
    if (buttons.filter(b => b.parentId === menuId).length > 0) {
      result = buttons.filter(b => b.parentId === menuId);
    }

    return result;
}
